package com.ruoyi.system.utils.rabbitMq.topic;//package com.letter.personal.util.rabbitMq.topic;
//
//import com.letter.personal.service.SgYsgService;
//import com.letter.personal.util.JsonUtils;
//import com.rabbitmq.client.Channel;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.util.Date;
//
//@Component
//public class TopicReceiver2 {
//
//    @Autowired
//    private SgYsgService sgYsgService;
//    @RabbitHandler
//    @RabbitListener(queues = "topic.2")
//    public void topic2(String datas, Channel channel, Message message) {
//        System.err.println("direct222222222222222222222222222222222收到  : " + datas +"收到时间"+new Date());
//        try {
//            sgYsgService.executeValidateNew(JsonUtils.jsonToMap(datas));
//            //告诉服务器收到这条消息 已经被我消费了 可以在队列删掉 这样以后就不会再发了 否则消息服务器以为这条消息没处理掉 后续还会在发
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
//            System.out.println("消费成功");
//        } catch (IOException e) {
//            e.printStackTrace();
//            //丢弃这条消息
//            //channel.basicNack(message.getMessageProperties().getDeliveryTag(), false,false);
//            System.err.println("消费失败");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//}
